package com.audaque.springboot.foshanupload.web.raspcloud.controller;

import com.audaque.springboot.foshanupload.web.raspcloud.entity.UserGroupRoleRel;
import com.audaque.springboot.foshanupload.web.raspcloud.req.UserGroupRoleRelReq;
import com.audaque.springboot.foshanupload.web.raspcloud.service.IUserGroupRoleRelService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * <p>
 * 后台用户组和角色关系表 前端控制器
 * </p>
 *
 * @author chinaben
 * @since 2025-07-02
 */
@RestController

@Api(value = "后台用户组和角色关系表 前端控制器")

@RequestMapping("/userGroupRoleRel")
public class UserGroupRoleRelController {


    @Autowired
    private IUserGroupRoleRelService iUserGroupRoleRelService;

    @PostMapping(value = "/page")
    @ApiOperation(value = "后台用户组和角色关系表 分页查询")
    public Page<UserGroupRoleRel> page(@RequestBody UserGroupRoleRelReq req) {
        QueryWrapper queryWrapper = new QueryWrapper(req);
        Page<UserGroupRoleRel> page = iUserGroupRoleRelService.page(new Page<>(req.getPage(), req.getRows()), queryWrapper);
        return page;
    }


    @PostMapping(value = "/list")
    @ApiOperation(value = "后台用户组和角色关系表 列表查询")
    public List<UserGroupRoleRel> list(@RequestBody UserGroupRoleRelReq req) {
        QueryWrapper queryWrapper = new QueryWrapper(req);
        List<UserGroupRoleRel> list = iUserGroupRoleRelService.list(queryWrapper);
        return list;
    }


    @GetMapping(value = "/{id}")
    @ApiOperation(value = "后台用户组和角色关系表 单体查询")
    public UserGroupRoleRel getById(@PathVariable("id") String id) {
        UserGroupRoleRel one = iUserGroupRoleRelService.getById(id);
        return one;
    }

    @PostMapping(value = "/create")
    @ApiOperation(value = "后台用户组和角色关系表 创建")
    public void create(@RequestBody UserGroupRoleRel params) {
        iUserGroupRoleRelService.save(params);
    }

    @PostMapping(value = "/delete/{id}")
    @ApiOperation(value = "后台用户组和角色关系表 删除")
    public void delete(@PathVariable("id") String id) {
        iUserGroupRoleRelService.removeById(id);
    }


    @PostMapping(value = "/update")
    @ApiOperation(value = "后台用户组和角色关系表 更新")
    public void update(@RequestBody UserGroupRoleRel params) {
        iUserGroupRoleRelService.updateById(params);
    }


}
